﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using ChinaDynastyTours.Controls;

namespace ChinaDynastyTours.Views
{
    public partial class GuideEvaluateAnalysisForm : DevExpress.XtraEditors.XtraForm
    {
        public GuideEvaluateAnalysisForm()
        {
            InitializeComponent();
        }

        private void GuideEvaluateAnalysisForm_Load(object sender, EventArgs e)
        {
            tbTravels.Properties.DataSource = BaseInfoCtrl.GetProviderData(new ProviderTypeEnum[]{ProviderTypeEnum.旅行社});
            tbFromDate.DateTime = DateTime.Now;
            tbToDate.DateTime = DateTime.Now.AddDays(7);
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            guideEvaluateGridControl.DataSource = GuideEvaluateCtrl.GetGuideEvalAnalysis(tbTravels.Text, tbFromDate.DateTime.ToString("yyyy-MM-dd"), tbToDate.DateTime.ToString("yyyy-MM-dd"));
        }

        private void guideFeedbackGridView_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (e.FocusedRowHandle < 0) return;

            string ciceroniID = guideEvaluateGridView.GetRowCellValue(e.FocusedRowHandle, "CiceroniID").ToString();

            guideEvaluateDetailGridControl.DataSource = GuideEvaluateCtrl.GetGuideEvalAnalysisDetail(ciceroniID, tbFromDate.DateTime.ToString("yyyy-MM-dd"), tbToDate.DateTime.ToString("yyyy-MM-dd"));
        }
    }
}